var t = getApp();

Component({
    properties: {
        role: {
            type: Number,
            value: 2
        },
        city: {
            type: String,
            value: ""
        },
        province: {
            type: String,
            value: ""
        },
        date: {
            type: String,
            value: ""
        },
        timepoint: {
            type: Number,
            value: 1
        },
        isShow: {
            type: Boolean,
            value: !1,
            observer: function(t, a) {
                1 == t && this.data.isFirstLoad && this.getData(!0);
            }
        },
        reset: {
            type: Boolean,
            value: !1,
            observer: function(t, a) {
                1 == t && 0 == a && (this.data.isFirstLoad = !0, this.data.pageNo = 1, this.data.isShow && this.getData(!0));
            }
        }
    },
    data: {
        users: [],
        pageNo: 1,
        total: -1,
        isFirstLoad: !0
    },
    methods: {
        lower: function(t) {
            this.getData(!1);
        },
        tapAvatar: function(a) {
            var e = a.currentTarget.dataset.accesstoken;
            t.util.navToUserHome(e);
        },
        getData: function(a) {
            var e = this, i = e.data.date.substring(0, 4) + "-" + e.data.date.substring(4, 6) + "-" + e.data.date.substring(6, 8);
            t.network.post({
                url: t.url.plannerSearchSchedule,
                params: {
                    pageNo: e.data.pageNo,
                    pageSize: 20,
                    province: e.data.province,
                    city: e.data.city,
                    role: e.data.role,
                    scheduleDate: i,
                    time: e.data.timepoint
                },
                before: function() {
                    wx.showNavigationBarLoading();
                },
                success: function(i) {
                    if (1 == i.data.result) {
                        var o = [];
                        a || (o = e.data.users), o = o.concat(i.data.data.users);
                        var s = e.data.pageNo + 1;
                        e.setData({
                            total: i.data.data.total,
                            users: o,
                            pageNo: s,
                            isFirstLoad: !1
                        }), a || e.triggerEvent("myevent", {}, {});
                    } else t.util.showToast(i.data.message);
                },
                fail: function() {
                    t.util.showToast("获取数据失败");
                },
                complete: function() {
                    wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
                }
            });
        }
    },
    ready: function() {
        this.data.isShow && this.getData(!0);
    }
});